﻿using System;
using System.Threading.Tasks;
using Windows.UI.Xaml;

// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236

namespace com.IronOne.BoardPACWinApp.View.UserControl
{
    public sealed partial class ContentDialog
    {
        public delegate Task GetPaperApprovalCommentDel(string comment);

        //AppBar topAppBar;
        //AppBar bottomAppBar;

        public ContentDialog()
        {
            InitializeComponent();
        }

        public static event GetPaperApprovalCommentDel GetPaperApprovalCommentEvt;

        public void ShowPopup()
        {
            try
            {
                MRect1.Height = Window.Current.Bounds.Height;
                MRect1.Width = Window.Current.Bounds.Width;

                PopStk.Width = Window.Current.Bounds.Width / 2;
                PopStk.Height = Window.Current.Bounds.Height * 0.3;
                TxbComment.Height = PopStk.Height / 2.5;
                TxbComment.Focus(FocusState.Programmatic);

                ContentPopup.IsOpen = true;
                ContentPopup.IsLightDismissEnabled = false;
                //topAppBar.IsEnabled = false;
                //bottomAppBar.IsEnabled = false;
            }
            catch (Exception)
            {
            }
        }

        public void ClosePopup()
        {
            ContentPopup.IsOpen = false;
            //topAppBar.IsEnabled = true;
            //bottomAppBar.IsEnabled = true;
        }

        private async void Done_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (GetPaperApprovalCommentEvt != null) await GetPaperApprovalCommentEvt(TxbComment.Text);
                ClosePopup();
            }
            catch (Exception)
            {
            }
        }
    }
}